package com.firstgroup.service.Impl;

import com.firstgroup.domain.Comment;
import com.firstgroup.repository.CommentRepository;
import com.firstgroup.repository.UserRepository;
import com.firstgroup.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    CommentRepository commentRepository;
    @Autowired
    UserRepository userRepository;

    /**
     * 遍历一面评论
     * @param interviewerId
     * @param state
     * @return
     */
    @Override
    public List<Comment> findByInterviewrIdAndState(Integer interviewerId, String state) {

        return commentRepository.findByInterviewrIdAndState(interviewerId, state);
    }

    @Override
    public Optional<Comment> findComments(int interviewerId) {

        return commentRepository.findById(interviewerId);
    }

    @Override
    public List<Comment> findCountss(int interviewerId) {
        return commentRepository.findByInterviewrId(interviewerId);
    }

    @Override
    public Comment addComments(Comment comment) {

        Comment comment1=commentRepository.save(comment);
        return comment1;
    }

    public List<Comment> findByInterviewerIdAndStateTwo(Integer interviewerId,String state){
      List<Comment> list= commentRepository.findByInterviewrIdAndState(interviewerId, state);
        return list;
    }






}
